<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
//
//Route::middleware('auth:api')->get('/user', function (Request $request) {
//    return $request->user();
//});
Route::group(["namespace" => 'Api'], function () {
    Route::get('getInfo', 'TestController@index');
    Route::post('logout', 'TestController@index');
    Route::post('login', 'TestController@login');
});
//没有登录
Route::group(["namespace" => 'Api'], function () {
    //用户相关
    Route::group(["prefix" => 'user'], function ($router) {
        $router->post('register', 'UserController@registerUser');//账号密码注册
        $router->post('login_pass', 'UserController@loginPass');//密码登录
        $router->post('mini_login', 'UserController@miniLogin');//小程序登录

    });
});
Route::group(["namespace" => 'Api', 'prefix' => 'wechat'], function ($router) {
    $router->get('home', 'WechatController@index');//订阅消息入口
});

//不要求强制登录
Route::group(["namespace" => 'Api', 'middleware' => ['user']], function () {
    Route::group(["prefix" => 'user'], function ($router) {
        $router->get('shop', 'UserCenterController@shopInfo');//店铺信息
    });

    Route::group(["prefix" => 'platform'], function ($router) {
        $router->get('resource', 'PlatformController@resourceList');//平台资源
        $router->get('wechat_message_list', 'PlatformController@wechatMessageList');//订阅消息列表
        $router->get('help_list', 'PlatformController@helpList');//帮助中心列表
        $router->get('help_detail', 'PlatformController@helpDetail');//帮助中心详情
        $router->post('add_dragon_view', 'PlatformController@dragonView');//添加来过的人
        $router->post('create_share_card', 'PlatformController@createShareCard');//生成分享卡片
        $router->post('create_share_poster', 'PlatformController@createSharePoster');//生成分享海报
    });
    Route::group(["prefix" => 'cluster'], function ($router) {
        $router->get('detail', 'ClusterController@detail');//群详情
    });
    Route::group(["prefix" => 'drag'], function ($router) {
        $router->get('lists', 'DragController@lists');//发现团购
        $router->get('detail', 'DragController@detail');//团购详情
        $router->get('shop_drag_lists', 'DragController@shopDragList');//店铺主页
    });
    Route::group(["prefix" => 'order'], function ($router) {
        $router->get('statics', 'OrderController@statics');//接龙订单数据统计
        $router->get('serial', 'OrderController@serial');//接龙订单（定时取）
        $router->get('lists', 'OrderController@lists');//接龙列表（单订单）
        $router->get('drag_statics', 'OrderController@dragStatics');//接龙详情页数据统计
    });
});

//要求登录
Route::group(["namespace" => 'Api', 'middleware' => ['user.auth']], function () {
    Route::group(["prefix" => 'user'], function ($router) {
        $router->get('main', 'UserCenterController@userInfo');
        $router->post('save', 'UserCenterController@updateUserInfo');
        $router->post('logout', 'UserController@logout');

        $router->post('subscribe', 'UserCenterController@subscribe');//订阅和取消订阅
        $router->post('apply_publish', 'UserController@applyPublish');//申请发布接龙权限
    });
    Route::group(["prefix" => 'drag'], function ($router) {
        $router->post('save', 'DragController@save');//团购新增、编辑
        $router->get('my_attempt', 'DragController@myAttempt');//发现接龙-我参与的
        $router->post('end', 'DragController@endDrag');//结束接龙
        $router->post('remove', 'DragController@removeDrag');//删除接龙
        $router->get('check_dragon', 'DragController@checkHadPay');//检查是否可以编辑接龙
        $router->post('export_dragon', 'DragController@exportDragon');//导出单条接龙数据
    });

    Route::group(["prefix" => 'order'], function ($router) {

        $router->post('create', 'OrderController@createOrder');//接龙
        $router->post('create_refund', 'OrderController@createRefundOrder');//手动取消接龙订单
        $router->post('verify', 'OrderController@verifyOrder');//核销接龙
        $router->get('single_dragon_statics', 'OrderController@singleDragonStatics');//接龙数据统计
        $router->get('total_statics', 'OrderController@totalStatics');//总数据统计
    });
    Route::group(["prefix" => 'cluster'], function ($router) {
        $router->post('create', 'ClusterController@add');//创建、编辑群
        $router->get('lists', 'ClusterController@lists');//群列表
        $router->post('dissolve', 'ClusterController@dissolve');//解散群

        $router->get('member_list', 'ClusterController@memberLists');//群成员
        $router->post('set_admin', 'ClusterController@setAdmin');//设为管理员
        $router->post('remove_member', 'ClusterController@removeMember');//删除群成员
        $router->post('add_member', 'ClusterController@addMember');//添加群成员
    });

    Route::group(["prefix" => 'trade'], function ($router) {
        $router->post('to_pay', 'TradeController@toPay');//去支付
    });

    Route::group(["prefix" => 'upload'], function ($router) {
        $router->post('images', 'UploadController@upload');
    });


});

